package gui.calendarview;

import java.util.Date;

import no.ntnu.fp.model.ActivityModel;
import no.ntnu.fp.swingutil.CalendarTools;

public class ListElement {
	
	private Date hourOfDay;
	private ActivityModel model;
	private boolean displayHourOfDay, isSelected;
	private CalendarTools ct;
	
	public ListElement(Date hourOfDay, ActivityModel model, boolean displayHourOfDay) {
		setHourOfDay(hourOfDay);
		setModel(model);
		setDisplayHourOfDay(displayHourOfDay);
		ct = new CalendarTools();
	}

	public Date getHourOfDay() {
		return hourOfDay;
	}

	public void setHourOfDay(Date hourOfDay) {
		this.hourOfDay = hourOfDay;
	}

	public ActivityModel getModel() {
		return model;
	}

	public void setModel(ActivityModel model) {
		this.model = model;
	}
	
	public boolean isDisplayHourOfDay() {
		return displayHourOfDay;
	}

	public void setDisplayHourOfDay(boolean displayHourOfDay) {
		this.displayHourOfDay = displayHourOfDay;
	}
	
	public boolean isSelected() {
		return isSelected;
	}

	public void setSelected(boolean isSelected) {
		this.isSelected = isSelected;
	}

	public String toString() {
		int hour = ct.getHourOfDay(getHourOfDay());
		String sHour = Integer.toString(hour);
		if ( hour < 10 ) {
			sHour = "0" + sHour;
		}
		
		int minute = ct.getMinute(getHourOfDay());
		String sMinute = Integer.toString(minute);
		if ( minute < 10 ) {
			sMinute = "0" + sMinute;
		}
		
		if ( displayHourOfDay )
			return sHour + ":" + sMinute + "    " + ( getModel() == null ? "" : getModel().toString() );
		return " " + ( getModel() == null ? "" : getModel().toString() );
	}
	
}
